﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfWordsLearner
{
	public sealed class TestGenerator
	{
		int m_wordCount = 0;
		public TestGenerator()
		{
			m_wordCount = 10;
		}

		public TestGenerator(int count)
		{
			m_wordCount = count;
		}

		public int WordsCount
		{
			get { return m_wordCount; }
			set { m_wordCount = value; }
		}

		public List<Model.TestWordModel> GenerateTestSet()
		{
			List<int> wordsIndexes = new List<int>();
			Random r = new Random();
			int wordCount = WordsManager.Instance.WorsdCount;
			for (int i = 0; i < m_wordCount; i++)
			{
				int wordIndx = r.Next(0, wordCount);
				while (wordsIndexes.Contains(wordIndx))
				{
					wordIndx = r.Next(0, wordCount);
				}
				wordsIndexes.Add(wordIndx);
			}

			return WordsManager.GenerateTestWords(wordsIndexes);
		}
	}

	public sealed class LerningModelGenerator
	{
		int m_wordCount = 0;

		public LerningModelGenerator()
		{
			m_wordCount = 10;
		}

		public LerningModelGenerator(int count)
		{
			m_wordCount = count;
		}

		public int WordsCount
		{
			get { return m_wordCount; }
			set { m_wordCount = value; }
		}

		public List<Model.LearnItem> GenerateLearningCourse()
		{
			List<int> wordsIndexes = new List<int>();
			Random r = new Random();
			int wordCount = WordsManager.Instance.WorsdCount;
			for (int i = 0; i < m_wordCount; i++)
			{
				int wordIndx = r.Next(0, wordCount);
				while (wordsIndexes.Contains(wordIndx))
				{
					wordIndx = r.Next(0, wordCount);
				}
				wordsIndexes.Add(wordIndx);
			}

			return WordsManager.GenerateWordsToLearn(wordsIndexes);
		}

		internal List<Model.LearnItem> GenerateLearningCourseComplicated()
		{
			return WordsManager.GenerateWordsToLearn(null, true, this.m_wordCount);
		}
	}
}
